﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Hammock;
using Hammock.Web;
using Microsoft.Phone.Controls;
using Newtonsoft.Json;

namespace MyMeetup.Controls
{
    public partial class AlbumList : UserControl
    {
        public int AlbumId { get; set; }
        public List<Photo> Photos { get; set; }
        
        public AlbumList()
        {
            InitializeComponent();
        }

        public void Bind()
        {
            Dispatcher.BeginInvoke(() =>
            {
                Thumbnails.ItemsSource = Photos;

            });
        }


        private void ImageClick(object sender, RoutedEventArgs e)
        {
            var selectedImage = ((Button)sender).DataContext as Photo;
            (App.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/PhotoPage.xaml?albumid=" + AlbumId + "&url=" + selectedImage.photo_link, UriKind.Relative));
            FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
            root.DataContext = Photos;
        }


    }
}
